import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import wasm from 'vite-plugin-wasm'
import path from "node:path";

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      dts: 'src/types/auto-imports.d.ts',
      vueTemplate: true,
      imports: [
        'vue',
        'vue-router',
        '@vueuse/core',
        {
          'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar'],
        },

      ],
      dirs: [path.resolve('src/auto-import')],
    }),
    // AutoImport({
    //
    //   vueTemplate: true,
    //   dirs: [
    //     path.resolve('src/auto-import'),
    //   ],
    //   dts: './auto-imports.d.ts',
    //   eslintrc: {
    //     enabled: true,
    //     filepath: './.eslintrc-auto-import.json',
    //     globalsPropValue: true,
    //   },
    // }),
    Components({
      resolvers: [NaiveUiResolver()],
    }),
    wasm(),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src/'),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        silenceDeprecations: ['legacy-js-api'],
        additionalData: `@import "@/style/variables.scss";`
      },
    },
  },
  server: {
    port: 14558,
    proxy: {
      '/api': {
        target: 'https://musicapi.aizrf.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
})
